{% load crispy_forms_tags %}
{% load i18n %}
<div class="card drop
    {% if condition.condition_type == ConditionType.AFTER %}
      after
    {% elif condition.condition_type == ConditionType.TODO %}
      to_do
    {% elif condition.condition_type == ConditionType.BEFORE %}
      before
    {% else %}
      unconditioned
    {% endif %}" data-id="{{ condition.id }}">
  <div class="card-header">
    <div class="row d-flex" style="width: 103% !important;">
      <div class="col-10">
        <h4 class="card-title">
          {% if condition.condition_type == ConditionType.AFTER %}
            {% blocktranslate with days=condition.days time=condition.time %}On day {{ days }} at {{ time }}{% endblocktranslate %}
          {% elif condition.condition_type == ConditionType.TODO %}
            {% translate "When these tasks are completed:" %}
            <div id="div_id_condition_to_do">
              {% for todo in condition.condition_to_do.all %}
                <span class="badge bg-blue-lt mt-1">{{ todo.name }}</span>
              {% endfor %}
            </div>
          {% elif condition.condition_type == ConditionType.ADMIN_TASK %}
            {% translate "When these admin tasks are completed:" %}
            <div id="div_id_condition_admin_task">
              {% for admin_task in condition.condition_admin_tasks.all %}
                <span class="badge bg-blue-lt mt-1">{{ admin_task.name }}</span>
              {% endfor %}
            </div>
          {% elif condition.condition_type == ConditionType.BEFORE %}
            {% if sequence.is_onboarding %}
              {% blocktranslate with days=condition.days time=condition.time %}{{ days }} days before starting at {{ time }}{% endblocktranslate %}
            {% elif condition.days == 0 %}
              {% blocktranslate with days=condition.days time=condition.time %}On termination day at {{ time }}{% endblocktranslate %}
            {% else %} {# offboarding sequence #}
              {% blocktranslate with days=condition.days time=condition.time %}{{ days }} workday(s) before termination at {{ time }}{% endblocktranslate %}
            {% endif %}
          {% elif condition.condition_type == ConditionType.INTEGRATIONS_REVOKED %}
            {% blocktranslate %}When all access has been revoked{% endblocktranslate %}
          {% else %}
            {% translate "Without any trigger - assign directly" %}
          {% endif %}
        </h4>
      </div>
      {% if not disable_delete and condition.condition_type != ConditionType.WITHOUT %}
      <div class="col-2 text-end">
        <button class="btn btn-azure btn-sm" onclick="editCondition({{condition.id}})">
          {% include "_edit_icon.html" %}
        </button>
        <button class="btn btn-danger btn-sm" style="margin-right: 4px" hx-delete="{% url 'sequences:condition-delete' object.id condition.id %}" hx-target="closest li" hx-swap="outerHTML">
          <svg xmlns="http://www.w3.org/2000/svg" style="margin: 0 -0.25rem 0 -.25rem" class="icon icon-tabler icon-tabler-x" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
            <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
            <line x1="18" y1="6" x2="6" y2="18"></line>
            <line x1="6" y1="6" x2="18" y2="18"></line>
          </svg>
        </button>
      </div>
      {% endif %}
    </div>
  </div>
  <div class="card-body">
    {% include "_condition_body.html" %}
  </div>
</div>
